import { ObjectOnlyPushSet } from '../../../Func/uniFunc/Func/ObjectOnlyPushSet_operate';
import { getDoc_styleSheet_className } from '../../Func';

const fromToAnima_keyframeObjTag = 'fromToAnima_keyframeObj';

let keepKeysArr = [
  'position',
  'padding-top',
  'padding-left',
  'padding-bottom',
  'padding-right',
];

class fromToAnima_keyframeObj {
  get [Symbol.toStringTag]() {
    return fromToAnima_keyframeObjTag;
  }

  /**
   *
   * @param {HTMLElement} element
   */
  constructor(element) {
    this.#ooset(element.style);
    for (const className of element.classList) {
      // console.log(className);
      let uni_styleSheet = getDoc_styleSheet_className(className);
      this.#ooset(uni_styleSheet);
    }
  }

  data = [];

  #ooset(uniStyle) {
    if (uniStyle == null) {
      return;
    }
    for (const styleDeclare of uniStyle) {
      if (!ObjectOnlyPushSet(this, styleDeclare, uniStyle[styleDeclare])) {
        // this[styleDeclare] = uniStyle[styleDeclare];
      }
    }
  }

  toStringStyle() {
    let ret = [];
    for (const key of this.data) {
      if (keepKeysArr.includes(key)) {
        continue;
      }
      ret.push(`${key} : ${this[key]};`);
    }
    return ret.join('\n\t\t');
  }
}

export { fromToAnima_keyframeObj };
